<template>
  <!--招采管理-班组招采列表-应标结果详情弹窗-表单-->
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :model="model" :rules="validatorRules">
        <!-- 主表单区域 -->
        <a-row class="form-row" :gutter="16">
          <a-col :lg="8">
            <a-form-model-item label="招标名称" prop="name">
              <a-input v-model="model.name" placeholder="请输入招标名称" />
            </a-form-model-item>
          </a-col>
          <a-col :lg="8">
            <a-form-model-item label="所属项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="project">
              <a-input v-model="model.project" placeholder="请输入项目"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :lg="8">
            <a-form-model-item label="结标时间" prop="traneIncTime">
              <j-date showTime valueFormat="YYYY-MM-DD" v-model="model.traneIncTime" />
            </a-form-model-item>
          </a-col>
          <a-col :span="15" style="margin-right: -250px">
            <a-form-model-item label="技术要求(上传文件包)" prop="fileList">
              <j-upload v-model="model.technicalRequirements"></j-upload>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-button type="primary" @click="handleSupplier" icon="search" style="margin-left: 8px"
                >选择供应商</a-button
              >
            </a-form-model-item>
          </a-col> -->
        </a-row>

        <!-- 子表单区域 -->
        <a-tabs defaultActiveKey="1">
          <a-tab-pane tab="招标信息" key="1">
            <div>
              <a-row type="flex" style="margin-bottom: 10px" :gutter="16">
                <!-- <a-col :span="4">班组分类</a-col> -->
                <!-- <a-col :span="4">二级分类</a-col>
                <a-col :span="3">三级分类</a-col> -->
                <a-col :span="4">项目名称</a-col>
                <a-col :span="4">计量单位</a-col>
                <a-col :span="4">工程量</a-col>
                <a-col :span="4">综合单价</a-col>

                <a-col :span="4">合价</a-col>
                <a-col :span="1">操作</a-col>
              </a-row>

              <a-row
                type="flex"
                style="margin-bottom: 10px"
                :gutter="16"
                v-for="(item, index) in model.biddingMaterialsList"
                :key="index"
              >

                <a-col :span="4">
                  <a-form-model-item>
                    <a-form-model-item style="width: 160px" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
                      <a-input v-model="item.name" placeholder="请输入项目名称"></a-input>
                    </a-form-model-item>
                  </a-form-model-item>
                </a-col>

                <a-col :span="4">
                  <a-form-model-item>
                    <a-input v-model="item.unit" :options="unit" placeholder="计量单位"></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="4">
                  <a-form-model-item>
                    <a-input v-model="item.num" placeholder="工程量"></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="4">
                  <a-form-model-item>
                    <a-input v-model="item.price" placeholder="综合单价"></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="4">
                  <a-form-model-item>
                    <a-input v-model="item.money" placeholder="合价"></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="1">
                  <a-form-model-item>
                    <a-icon type="minus-circle" @click="delRcruit(index)" style="fontsize: 20px" />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </div>
          </a-tab-pane>
        </a-tabs>
      </a-form-model>
    </j-form-container>

  </a-spin>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
import JDate from '@/components/jeecg/JDate'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { axios } from '@/utils/request'
import signMd5Utils from '@/utils/encryption/signMd5Utils'
// import WtPublicPriceSupplierModal from './WtPublicBiddingPriceSupplierModal.vue'
// import WtPublicPriceSupplierForm from './WtPublicBiddingPriceSupplierForm.vue'
export default {
  name: 'WtPublicBiddingRecruitForm',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    JDate,

    // MaterialSupplier,
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
    id: {
      type: String,
    },
  },

  data() {
    return {
      id: '',

      title: '操作',
      visible: false,
      model: {
        name: '',
        project: '',
        traneIncTime: '',
        technicalRequirements: [],
        biddingMaterialsList: [
          {
            name: '',
            num: '',
            unit: '',
            price: '',
            money: '',
          },
        ],
      },

      treeData: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
        //  name: [{ required: true, message: '招采名称不能为空', trigger: 'blur' }],
      },
      url: {
        add: '',
        edit: '/bidding/wtPublicBidding/edit',
        orderCustomerList: '/test/jeecgOrderMain/queryOrderCustomerListByMainId',
        orderTicketList: '/test/jeecgOrderMain/queryOrderTicketListByMainId',
        list: '/bidding/wtPublicBiddingMaterials/queryList',
      },
      dictOptions: {},
      superFieldList: [],
      queryParam: { type: '0', publicBiddingId: this.id },
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: 'id',
          align: 'center',
          dataIndex: 'id',
        },
        {
          title: '名称',
          align: 'center',
          dataIndex: 'name',
        },

        {
          title: '联系人',
          align: 'center',
          dataIndex: 'relation',
        },
        {
          title: '电话',
          align: 'center',
          dataIndex: 'phone',
        },
        {
          title: '地址',
          align: 'center',
          dataIndex: 'address',
        },
        {
          title: '评分',
          align: 'center',
          dataIndex: 'score',
        },
      ],
    }
  },
  created() {
    // console.log('111', this.id)
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  methods: {

    add() {
      this.edit({})
    },
    edit(record) {
      let url = '/bidding/wtPublicBiddingMaterials/queryList'
      let parameter = {
        publicBiddingId: record.id,
      }

      let sign = signMd5Utils.getSign(url, parameter)

      let signHeader = { 'X-Sign': sign, 'X-TIMESTAMP': signMd5Utils.getTimestamp() }

      axios({
        url: url,
        method: 'get',
        params: parameter,
        headers: signHeader,
      }).then((res) => {
        this.model.biddingMaterialsList = res.result
      })
      this.model = Object.assign(
        {
          biddingMaterialsList: [{}],
        },
        record
      )

      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
    },

    handleCancel() {
      this.close()
    },
    addRcruit() {
      this.model.biddingMaterialsList.push({})

      this.$forceUpdate()
    },
    delRcruit(index) {
      this.model.biddingMaterialsList.splice(index, 1)
      this.$forceUpdate()
      this.model.biddingMaterialsList.model =
        this.model.biddingMaterialsList.num =
        this.model.biddingMaterialsList.unit =
        this.model.categoryOneId =
        this.model.categoryTwoId =
        this.model.categoryThreeId =
        this.model.biddingMaterialsList.platformProductName =
          ''
    },
  },
}
</script>
<style scoped>
.ant-btn {
  padding: 0 10px;
  margin-left: 3px;
}

.ant-form-item-control {
  line-height: 0px;
}

/** 主表单行间距 */
.ant-form .ant-form-item {
  margin-bottom: 10px;
}

/** Tab页面行间距 */
.ant-tabs-content .ant-form-item {
  margin-bottom: 0px;
}
</style>
